package com.briup.ptt.web.controller;

import com.briup.ptt.bean.Animal;
import com.briup.ptt.service.AnimalService;
import com.briup.ptt.util.Result;
import com.briup.ptt.util.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 杰瑞
 * @date 2025/8/18
 */
@Api(tags = "动物管理模块")
@RestController
@RequestMapping("/animal")
public class AnimalController {

    @Autowired
    private AnimalService animalService;

    @ApiOperation("新增或修改动物接口")
    @PostMapping("/saveOrUpdate")
    public Result saveOrUpdate(@RequestBody Animal animal){
        animalService.saveOrUpdate(animal);
        return ResultUtil.success();
    }

    @ApiOperation("根据ID删除动物接口")
    @DeleteMapping("/deleteById/{aAnimalId}")
    public Result deleteById(@PathVariable String aAnimalId){
        animalService.deleteById(aAnimalId);
        return ResultUtil.success();
    }

    @ApiOperation("批量删除动物接口")
    @DeleteMapping("/deleteByIdAll")
    public Result deleteById(@RequestBody List<String> ids){
        animalService.deleteById(ids);
        return ResultUtil.success();
    }


}
